'use strict';

var React = require('react');

var Dispatcher = require('../dispatchers/default');
var EventEmitter = require('events').EventEmitter;

var PanelRouterConstants = require('../constants/panelRouter');
var PanelRouterAction = require('../actions/panelRouter');



var assign = require('object-assign');

var EVENT = PanelRouterConstants.EVENT_MY_REPORT;


var PanelRoutertStore = assign({}, EventEmitter.prototype, {

    emitChange: function(obj) {
        this.emit(EVENT, obj);
    },

    addChangeListener: function(callback) {
        this.on(EVENT, callback);
    },

    removeChangeListener: function(callback) {
        this.removeListener(EVENT, callback);
    },
    dispatcherIndex: Dispatcher.register(function(payload) {
        console.log(payload, 'ROUTER');
        var action = payload.action;

        switch (action.actionType) {
            case PanelRouterConstants.PANEL_ROUTER:
                PanelRoutertStore.emitChange({
                    params: action.params,
                    eventName: PanelRouterConstants.PANEL_ROUTER
                });
                break;

            case PanelRouterConstants.PANEL_ROUTER_REFUSE:
                PanelRoutertStore.emitChange({
                    params: action.params,
                    eventName: PanelRouterConstants.PANEL_ROUTER_REFUSE
                });
                break;

            case PanelRouterConstants.PANEL_ROUTER_CART:
                PanelRoutertStore.emitChange({
                    params: action.params,
                    eventName: PanelRouterConstants.PANEL_ROUTER_CART
                });
                break;

            case PanelRouterConstants.PANEL_ROUTER_WORDS:
                PanelRoutertStore.emitChange({
                    params: action.params,
                    eventName: PanelRouterConstants.PANEL_ROUTER_WORDS
                });
                break;

            case PanelRouterConstants.PANEL_ROUTER_EDIT:
                PanelRoutertStore.emitChange({
                    params: action.params,
                    eventName: PanelRouterConstants.PANEL_ROUTER_EDIT
                });
                break;

            case PanelRouterConstants.PANEL_ROUTER_NOTICE:
                PanelRoutertStore.emitChange({
                    params: action.params,
                    eventName: PanelRouterConstants.PANEL_ROUTER_NOTICE
                });
                break;
        }

        return true;
    })

});

module.exports = PanelRoutertStore;